package cn.wl.pchart.tools;

import com.alibaba.fastjson.JSONObject;

// 处理通信信息
public class Communication {

    public static Signal getJsonFromMessage(String message) {

        // 解密
        try {
            message = Tools.aesDecrypt(message);
        } catch (Exception e)
        {
            String error = "聊天信息解密失败";
            e.printStackTrace();
            return new Signal(-1, error);
        }

        JSONObject result = null;
        try {
            result = JSONObject.parseObject(message);
            return new Signal(0, "获取JSON对象成功", result);
        } catch (Exception e)
        {
            String error = "聊天信息转换JSON对象失败";
            e.printStackTrace();
            return new Signal(-2, error);
        }
    }

}
